package com.terry.webutils;


import com.terry.errorutils.UnifyErrorInterface;
import javafx.collections.transformation.SortedList;

import java.io.Serializable;
import java.util.*;

public class BaseResult implements Serializable {
    private Boolean success;
    private List<Error> errors;
    private Set<String> errorKeys=new HashSet<String>();

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public List<Error> getList() {
        return errors;
    }

    public void setList(List<Error> errors) {
        this.success=false;
        this.errors = errors;
    }
    public void addError(String code,String errorMsg,String enErrorMsg){
        this.success=false;
        if(!this.errorKeys.contains(code)){
            this.errorKeys.add(code);
            if(null==this.errors){
                errors=new ArrayList<>();
            }
            errors.add(new Error(code,errorMsg,enErrorMsg));
        }
    }
    public void  addError(UnifyErrorInterface unifyErrorInterface){
this.addError(unifyErrorInterface.getcode(),unifyErrorInterface.getMsg(),unifyErrorInterface.getEnmsg());
    }

    public static void main(String[] args) {
        List<String> list=new ArrayList<>();
        list.add("a");
        list.add("b");
        list.add("3");
        Collections.reverse(list);
        
    }
}
